home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
MUBBS
/
MUBBS etc.cpt
/
Module Source
/
Module std routines
/
MUBBS Module.h
< prev
Wrap
Text File
|
1991-11-11
|
11KB
|
289 lines
/*
* MUBBS Module.h
*
* This program source code and it's compiled version is
* Copyright (c) 1991 N. Hawthorn.
* This program source code and it's compiled version IS NOT IN THE
* PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
* regarding use of this program source code and it's compiled version.
*
*
* Don't modify this file !
*
*/
#include "MacTypes.h"
/* All of my GLOBALS and stuff for each c file to use */
/* these values MUST remain the same */
#ifndef NULL
#define NULL ((void *) 0)
#endif
#define EOF (-1)
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define maxport 33 /* how many users we may have ever makes exactly maxport users */
#define maxnamelength 33 /* max username length */
struct GS { /* all this is provided to modules for possible modification */
int
u, /* THIS IS THE ACTIVE USER NUMBER !! (starts at 0!)
/* use this for every array's index ! */
users, /* how many actual users for this particular set up */
localuser, /* what user number the local user is (it's users -1) */
stacksize, /* stacks for all, never over 32K !!*/
calls, /* number of calls total since boot up */
connects, /* number of connects since boot up */
logins, /* number of logins since boot up */
debuglevel, /* For debugging, will print special messages when over 1 */
resetmode, /* 0= no system reload, 1= program reload only, 2= total reset OK */
timeminute, /* One minute count, gets reset to 0 at 10 minutes */
noprint, /* flag for stopping any print() to the Mac screen, for local log on */
forgetusers, /* flag to make all ports dead, for first sysop log on */
switchcount, /* count of times NOT switched, done in a IRQ, reset at switch */
reservedint1, /* reserved, DO NOT USE ! */
reservedint2, /* reserved, DO NOT USE ! */
reservedint3, /* reserved, DO NOT USE ! */
online[maxport], /* flag for when you are still online */
maxtime[maxport], /* max time to timeout in input routines, in TICKS 1000=15secs 3000=45secs */
timeon[maxport], /* minutes this user has been on this login */
timeallowed[maxport], /* minutes this user is allowed on for */
userpriv[maxport], /* users privledge level */
userlines[maxport], /* users terminal config for line counts */
usertimes[maxport], /* users number of times on (to detect new users) */
logmode[maxport], /* 0=No log file written for this user, 1=Log this user */
privacy[maxport], /* 0=Don't bother me, handled by a Chat Module */
linecnt[maxport], /* users actual output line count, the system does this for you */
cont[maxport], /* users flag for continous output, no stopping */
carrdet[maxport], /* for testing, detect carrier loss */
usedtr[maxport], /* flag for using DTR for hang up */
nocheck[maxport], /* flag for send to check for control characters (S or C) */
okcancel[maxport], /* flag for text file send cancels */
cancel[maxport], /* TRUE when cancel is pressed in the out routine */
monitor[maxport], /* The monitor flag, if TRUE shows all output to Mac screen */
chatmode[maxport], /* if >1 the chat module is called from in() */
local[maxport], /* flag to tell if this user is at the Mac screen & keyboard */
language[maxport], /* 0=english normal, 1=english with ANSI Graphics. */
noiseflag[maxport], /* TRUE if line noise is present (if noise detect module installed) */
frontend[maxport], /* TRUE if using a front end program (if front end module installed) */
answer[maxport], /* TRUE if it's OK to answer the line (for maint period) */
nottransfer[maxport], /* flag for when you are not in a transfer, doesn't strip ctls */
reservedint4[maxport], /* reserved, DO NOT USE ! */
reservedint5[maxport], /* reserved, DO NOT USE ! */
reservedint6[maxport], /* reserved, DO NOT USE ! */
reservedint7[maxport], /* reserved, DO NOT USE ! */
reservedint8[maxport]; /* reserved, DO NOT USE ! */
long
newstacksize, /* the total stack size allowed, system sets this up for you */
logincounts, /* counter of logins total for system */
timems, /* counter of 10 MS periods, gets reset each minute to 0 */
userfilepos[maxport], /* points to this users record in the userfile */
reservedlong1[maxport], /* reserved, DO NOT USE ! */
reservedlong2[maxport], /* reserved, DO NOT USE ! */
reservedlong3[maxport], /* reserved, DO NOT USE ! */
reservedlong4[maxport], /* reserved, DO NOT USE ! */
reservedlong5[maxport]; /* reserved, DO NOT USE ! */
float
version, /* this release of MUBBS version number */
reservedfloat1, /* reserved, DO NOT USE ! */
reservedfloat2, /* reserved, DO NOT USE ! */
reservedfloat3; /* reserved, DO NOT USE ! */
char
CR[maxport][4], /* This is the CRLF string use this, don't do a send("]"). */
username[maxport][maxnamelength], /* user's name */
userbaud[maxport][10], /* user's baudrate */
userlast[maxport][maxnamelength], /* last time user was on */
userlocation[maxport][65], /* user's location*/
sysopname[33], /* sysop's name for system */
systemname[41], /* this systems's name */
modulename[maxport][27], /* the name of the module being called now */
oldmodulename[maxport][27], /* the calling module's name (a copy of modulename) */
keyboardbuf[50], /* for buffering the Mac's keyborad DO NOT USE ! */
programmer[21], /* Returned from a module, the programmers "credits" name */
reservedchar1[maxport][maxnamelength], /* reserved, DO NOT USE ! */
reservedchar2[maxport][maxnamelength], /* reserved, DO NOT USE ! */
reservedchar3[maxport][maxnamelength], /* reserved, DO NOT USE ! */
reservedchar4[maxport][maxnamelength], /* reserved, DO NOT USE ! */
reservedchar5[maxport][maxnamelength]; /* reserved, DO NOT USE ! */
unsigned char
input[maxport];
long S; /* module call back routine pointer */
ProcPtr Js; /* module call back pointer to the routine */
int moduleresult; /* module result code, only valid right after return from module */
/* or set FALSE if module couldn't be called */
ProcPtr seropen; /* serial port open routine pointer */
ProcPtr serclose; /* serial port close routine pointer */
ProcPtr serflush; /* serial port flush routine pointer */
ProcPtr serin; /* serial port input routine pointer */
ProcPtr serout; /* serial port output routine pointer */
ProcPtr serblkin; /* Block serial port input routine pointer */
ProcPtr serblkout; /* Block serial port output routine pointer */
ProcPtr in; /* IN routine pointer */
ProcPtr out; /* OUT routine pointer */
ProcPtr blkin; /* Block IN routine pointer */
ProcPtr blkout; /* Block OUT routine pointer */
ProcPtr event1; /* Event loop routine pointer */
ProcPtr event2; /* Event loop routine pointer */
ProcPtr event3; /* Event loop routine pointer */
ProcPtr event4; /* Event loop routine pointer */
ProcPtr event5; /* Event loop routine pointer */
ProcPtr idle1; /* Idle loop routine pointer */
ProcPtr idle2; /* Idle loop routine pointer */
ProcPtr idle3; /* Idle loop routine pointer */
ProcPtr idle4; /* Idle loop routine pointer */
ProcPtr idle5; /* Idle loop routine pointer */
ProcPtr extra1; /* RESERVED, DO NOT USE !! */
ProcPtr extra2; /* RESERVED, DO NOT USE !! */
ProcPtr extra3; /* RESERVED, DO NOT USE !! */
ProcPtr extra4; /* RESERVED, DO NOT USE !! */
ProcPtr extra5; /* RESERVED, DO NOT USE !! */
}; /* end of struct "GS" */
/* Here's where we define our globals. In the "Main" file, we make them actual */
/* globals. In any others, they are "extern" so that your code can find them. */
/* this is done by maknig the word "globalx" change (nothing or extern). */
#ifdef INMAIN
#define globalx
#else
#define globalx extern
#endif
globalx struct GS *G; /* our pointer to the main module's global struct */
globalx int mode[maxport]; /* what mode this module was called in */
/* routines used to access the "call back" routines in the main module */
#define godoit hh=G->Js; asm{move.l hh,a1} asm{UNLK A6} asm{JMP (a1)}
/* this is so that we don't have to do the -> thing all the time ! */
#define u G->u
/* this stuff is so that we can call the "stdio" routines in the main module */
#ifndef __size_t
#define __size_t
typedef unsigned long size_t;
#endif
typedef unsigned long fpos_t;
typedef struct {
unsigned std : 1;
unsigned binary : 1;
unsigned eof : 1;
unsigned err : 1;
unsigned dirty : 1;
unsigned mybuf : 1;
unsigned append : 1;
unsigned delete : 1;
unsigned pushed : 1;
char one;
unsigned char pushc;
short refnum;
char *buf;
size_t size;
unsigned char *ptr;
size_t cnt;
fpos_t pos;
fpos_t len;
void *window;
int (*proc)();
} FILE;
/* are we in the "MUBBS Misc.c" file ?, if so don't compile this */
#ifndef INMUBBSMISC
extern int remove(char *);
extern int rename(char *, char *);
extern FILE *tmpfile(void);
extern char *tmpnam(char *);
extern int fclose(FILE *);
extern int fflush(FILE *);
extern FILE *fopen(char *, char *);
extern FILE *freopen(char *, char *, FILE *);
extern void setbuf(FILE *, char *);
extern int setvbuf(FILE *, char *, int, size_t);
extern int fprintf(FILE *, char *, ...);
extern int fscanf(FILE *, char *, ...);
extern int printf(char *, ...);
extern int scanf(char *, ...);
extern int sprintf(char *, char *, ...);
extern int sscanf(char *, char *, ...);
extern int vfprintf(FILE *, char *, void *);
extern int vprintf(char *, void *);
extern int vsprintf(char *, char *, void *);
extern int _vscanf(char *, void *);
extern int _vsscanf(char *, char *, void *);
extern int _vfscanf(FILE *, char *, void *);
extern int fgetc(FILE *);
extern char *fgets(char *, int, FILE *);
extern int fputc(int, FILE *);
extern int fputs(char *, FILE *);
extern int getc(FILE *);
extern int getchar(void);
extern char *gets(char *);
extern int putc(int, FILE *);
extern int putchar(int);
extern int puts(char *);
extern int ungetc(int, FILE *);
extern size_t fread(void *, size_t, size_t, FILE *);
extern size_t fwrite(void *, size_t, size_t, FILE *);
extern int fgetpos(FILE *, fpos_t *);
extern int fseek(FILE *, long, int);
extern int fsetpos(FILE *, fpos_t *);
extern long ftell(FILE *);
extern void rewind(FILE *);
extern void clearerr(FILE *);
extern int feof(FILE *);
extern int ferror(FILE *);
extern void perror(char *);
#endif
/* this should allow you to access these routines */
int __getc(FILE *);
int __putc(int, FILE *);
#define getc(fp) ((fp)->cnt-- ? (int) *(fp)->ptr++ : __getc(fp))
#define getchar() getc(stdin)
#define putc(c, fp) ((fp)->cnt-- > 1 ? (int) (*(fp)->ptr++ = (c)) : __putc(c, fp))
#define putchar(c) putc(c, stdout)
#define ferror(fp) ((int) (fp)->err)
#define feof(fp) ((int) (fp)->eof)